﻿using System;
using System.Collections.Generic;
using System.Text;
using LitJson;

using System.Net;
using System.IO;
using System.Threading;


namespace MiPruebaJSon
{
    class Ovnis
    {
        List<Ovni> _ovnis = null;

        public List<Ovni> ovnis
        {
            get
            {
                if (_ovnis == null)
                    _ovnis = new List<Ovni>();

                return _ovnis;
            }
            set
            {
                _ovnis = value;
            }
        }
    }

    class Ovni
    {
        public Ovni()
        {
            // 
        }

        public Ovni(string tiempo, string key, string lat, string lon, string vel)
        {
            _tiempo = tiempo;
            _key = key;
            _lat = lat;
            _lon = lon;
            _vel = vel;
        }

        string _tiempo = "";
        string _key = "";
        string _lat = "";
        string _lon = "";
        string _vel = "";

        public string tiempo
        {
            get { return _tiempo; }
            set { _tiempo = value; }
        }

        public string key
        {
            get { return _key; }
            set { _key = value; }
        }

        public string lat
        {
            get { return _lat; }
            set { _lat = value; }
        }

        public string lon
        {
            get { return _lon; }
            set { _lon = value; }
        }

        public string vel
        {
            get { return _vel; }
            set { _vel = value; }
        }
    }

    class Program
    {
        //static string ret = "{\"ovnis\":[{\"tiempo\":\"123456\",\"key\":\"28146297\",\"lat\":\"32.32423\",\"lon\":\"60.31233\",\"vel\":\"2.97\"},{\"tiempo\":\"123456\",\"key\":\"28146297\",\"lat\":\"32.32423\",\"lon\":\"60.31233\",\"vel\":\"2.97\"},{\"tiempo\":\"123456\",\"key\":\"28146297\",\"lat\":\"32.32423\",\"lon\":\"60.31233\",\"vel\":\"2.97\"}]}";

        static void Main(string[] args)
        {
            Ovnis ovnis = new Ovnis();

            ovnis.ovnis.Add(new Ovni("123456", "a28146297", "32.32423", "60.31233", "2.97"));
            ovnis.ovnis.Add(new Ovni("123457", "b28146297", "32.32423", "60.31233", "2.97"));
            ovnis.ovnis.Add(new Ovni("123458", "c28146297", "32.32423", "60.31233", "2.97"));

            string ret = JsonMapper.ToJson(ovnis);

            Ovnis chauchas = JsonMapper.ToObject<Ovnis>(ret);

            Console.WriteLine(chauchas.ovnis.Count);
            Console.ReadLine();
        }
    }
}
